package com.yami.shop.controller;


import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.dto.user.GroupNotificationMessageDTO;
import com.yami.shop.service.impl.RongYunMsgServiceImpl;
import com.yami.shop.vo.message.message.GroupMessageVo;
import com.yami.shop.vo.message.message.PrivateMessageVo;
import com.yami.shop.vo.message.message.UltraGroupMessageVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 消息管理
 */
@RestController
@RequestMapping("/account/im/msg")
@Schema(description = "app-钱包IM消息管理")
public class RongYunMessageController {

    @Autowired
    private RongYunMsgServiceImpl messageService;

    @PostMapping("system_group_msg_send")
    @Operation(summary =  "消息管理-发送群聊消息-普通消息发送")
    public ServerResponseEntity<String> groupMessagePublish(@RequestBody @Valid GroupMessageVo recallMessageVo) throws Exception {
        return messageService.publishGroup(recallMessageVo);
    }
    @PostMapping("system_group_advice_msg_send")
    @Operation(summary =  "消息管理-发送群聊消息-群组通知消息")
    public ServerResponseEntity<String> groupMessagePublishAdvice(@RequestBody @Valid GroupNotificationMessageDTO recallMessageVo) throws Exception {
        return messageService.sendGroupAdvice(recallMessageVo);
    }

    @PostMapping("system_private_msg_send")
    @Operation(summary =  "消息管理-发送单聊消息-普通消息发送")
    public ServerResponseEntity<String> publishMsg(@RequestBody @Valid PrivateMessageVo tempVo) throws Exception {
        return messageService.privatePublish(tempVo);
    }
    @PostMapping("system_private_ntf_msg_send")
    @Operation(summary =  "消息管理-发送单聊消息-小灰条消息发送")
    public ServerResponseEntity<String> privatePublishInfoNtf(@RequestBody @Valid PrivateMessageVo tempVo) throws Exception {
        return messageService.privatePublishInfoNtf(tempVo);
    }


    @PostMapping("/system_history_clean")
    @Operation(summary =  "清除历史消息 (如用户开通了单群聊消息云存储服务，可通过此接口按会话清除某用户指定时间之前服务端存储的历史消息，清除后用户在客户端无法再获取到存储到融云服务端历史消息，请谨慎执行此操作。)", description = "：如用户开通了单群聊消息云存储服务，可通过此接口按会话清除某用户指定时间之前服务端存储的历史消息，清除后用户在客户端无法再获取到存储到融云服务端历史消息，请谨慎执行此操作。")
    public ServerResponseEntity<String> historyClean(@RequestBody @Valid UltraGroupMessageVo messageVo) throws Exception {
        return messageService.historyClean(messageVo);
    }

}
